package com.study.skywalking.service.impl;

import com.study.skywalking.api.MyRestService;
import com.study.skywalking.dto.MyRestDTO;
import com.study.skywalking.dto.MyServerDTO;
import com.study.skywalking.service.IMyService;
import com.study.skywalking.vo.MyServerVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * Created by zhangbo on 2020/6/8.
 */
@Slf4j
@Service
public class MyServiceImpl implements IMyService {

    @DubboReference
    private MyRestService myRestService;

    @Override
    public MyRestDTO rest(MyServerVO restVO) {
        return myRestService.rest(restVO);
    }

    @Override
    public MyServerDTO myServer() {
        log.info("调用myServer方法");
        return myRestService.myServer();
    }

    @Override
    public MyServerDTO testException() {
        return myRestService.testException();
    }

    @Override
    public String testRedis() {
        String uid = UUID.randomUUID().toString().replaceAll("-", "");
        return myRestService.testRedis(uid);
    }

    @Override
    public String sendMessage() {
        List<String> messages = new ArrayList<>(50);
        for(int i = 0 ; i < 50 ; i++) {
            messages.add(UUID.randomUUID().toString().replace("-",""));
        }
        String result = myRestService.sendMessage(messages);
        return result;
    }
}
